package counter.com.configuration;

import java.util.HashMap;

public class TokenManager {
    private static TokenManager cookieManager;
    private HashMap<String, String> records;

    private TokenManager() {
        records = new HashMap<>();
    }

    public static TokenManager getInstance() {
        if (cookieManager == null) {
            cookieManager = new TokenManager();
        }
        return cookieManager;
    }


    public String getUsernameByToken(String cookieName) {
        return records.get(cookieName);
    }

    public void addToken(String token, String username) {
        records.put(token, username);
    }

    public void removeToken(String cookieName) {
        records.remove(cookieName);
    }
}
